package com.yl.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yl.dao.ICategoryDao;
import com.yl.model.Category;
@Service
public class CategoryService implements ICategoryService {

	
	@Resource
	private ICategoryDao categoryDao;
	
	/**
	 *显示所有商品分类
	 */
	@Override
	public Map findAll() {
		List<Category> list = categoryDao.findAll();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "查询成功");
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}

	/**
	 *根据id删除分类
	 */
	@Override
	public int del(int category_id) {
		return categoryDao.del(category_id);
	}

	/**
	 *新增分类
	 */
	@Override
	public int add(Category category) {
		return categoryDao.add(category);
	}

	/**
	 *显示推荐商品
	 */
	@Override
	public Map findAllstate() {
		List<Category> list = categoryDao.findAllstate();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "查询成功");
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}

	/**
	 *编辑商品
	 */
	@Override
	public int edit(Category category) {
		return categoryDao.edit(category);
	}

}
